-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added method error_contribution_from. #72
base: master
Are you sure you want to change the base?
Conversation
@lebigot Any thoughts? |
Sorry for the delay in responding. This function is useful, but it can really be a simple one-liner, so I prefer not to include it, because I want to keep the module as small as possible while making even powerful things easy enough to implement (like here): def error_contribution_from(self, filter_tag):
"""
Return the error contribution from specific error components.
Return the error contribution from error components for
which filter_tag(tag) is true.
"""
return sqrt(sum(error**2 for (var, error) in self.error_components().iteritems()
if filter_tag(var.tag))) |
I can see where you're coming from (keeping libraries small is good) but I think a function like this makes uncertainties much more valuable. Relying on the user to figure this out and reimplement it every time instead of providing it in the interface is an unnecessary barrier to entry. I'm not wedded to the idea of using a function like this; I think there must be a cleaner/clearer way to implement feature. Either way, I think it's worth thinking about how to expose this functionality straight from a I use this feature every day for my analysis and it's extremely useful (saving a lot of time). |
Perhaps an |
I like the idea of extending the UFloat class with this, thanks! I'm reopening this pull request as a kind of reminder. |
Codecov Report
@@ Coverage Diff @@
## master #72 +/- ##
==========================================
- Coverage 94.62% 94.33% -0.29%
==========================================
Files 12 12
Lines 1954 1960 +6
==========================================
Hits 1849 1849
- Misses 105 111 +6
Continue to review full report at Codecov.
|
The function error_contribution_from allows developers to discover the complete contribution from a set of tags specified by a predicate function.
d235894
to
842a45b
Compare
The function error_contribution_from allows developers to discover the complete contribution from a set of tags specified by a predicate function.
This is part way to address #70. Since Python is awesome (or uncertainties' authors are, reader's choice), tuples can be used for tags instead of strings. This means that with the new function
error_contribution_from
one can:Note
This pull request does not (yet!) include documentation changes. These will be added when the code is agreed upon.